package quick.start.core.connect.request;

public abstract class DefaultRequestBuilder {
    protected String url;
    protected HttpParams params;
    protected String cmdName;
    protected HttpParams headerParams;

    public DefaultRequestBuilder url(String url) {
        this.url = url;
        return this;
    }

    public DefaultRequestBuilder cmdName(String cmd) {
        this.cmdName = cmd;
        return this;
    }

    public DefaultRequestBuilder params(HttpParams params) {
        this.params = params;
        return this;
    }

    public DefaultRequestBuilder header(HttpParams headerParams) {
        this.headerParams = headerParams;
        return this;
    }

    public abstract RequestWrapper build();

    protected final RequestWrapper preBuild(RequestWrapper reqWrapper) {
        reqWrapper.url = url;
        reqWrapper.params = params;
        reqWrapper.headers = headerParams;
        reqWrapper.command = cmdName;
        return reqWrapper;
    }
}
